﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.CApTcEndModelingCmdEnabler
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands;

public class CApTcEndModelingCmdEnabler : ITxCommandEnabler
{
  private static List<TxApplicationModeEx> MODES_LIST = new List<TxApplicationModeEx>(1);

  public static List<TxApplicationModeEx> ModesList
  {
    get
    {
      if (CApTcEndModelingCmdEnabler.MODES_LIST.Count == 0)
      {
        TxApplicationModeEx applicationModeEx1 = new TxApplicationModeEx("KINEMATIC_EDITOR_MODE", false);
        CApTcEndModelingCmdEnabler.MODES_LIST.Add(applicationModeEx1);
        TxApplicationModeEx applicationModeEx2 = new TxApplicationModeEx("DEFINE_TOOL_MODE", false);
        CApTcEndModelingCmdEnabler.MODES_LIST.Add(applicationModeEx2);
      }
      return CApTcEndModelingCmdEnabler.MODES_LIST;
    }
    set => CApTcEndModelingCmdEnabler.MODES_LIST = value;
  }

  public bool Enable => this.ShouldEnable();

  private bool ShouldEnable()
  {
    bool flag = false;
    TxObjectList allItems = TxApplication.ActiveSelection.GetAllItems();
    if (((Collection<ITxObject>) allItems).Count == 1 && TxApplicationEx.IsInEnabledMode(CApTcEndModelingCmdEnabler.ModesList) && ((Collection<ITxObject>) allItems)[0] is ITxStorable && !(((Collection<ITxObject>) allItems)[0] is TxSweptVolume) && !(((Collection<ITxObject>) allItems)[0] is TxHuman) && ((Collection<ITxObject>) allItems)[0] is ITxProcessModelObject)
    {
      ITxStorable itxStorable = ((Collection<ITxObject>) allItems)[0] as ITxStorable;
      if (itxStorable.StorageObject is TxLocalStorage)
        flag = true;
      if (flag && TxEngineeringDataInternal.ObjectIsResourceAppearance((ITxObject) itxStorable))
        flag = false;
    }
    return flag;
  }
}
